home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / MacPerl 506 appl folder.sit / MacPerl 506 appl folder / Mac_Perl_506r1m_appl / lib / Cwd.pm < prev    next >
Text File  |  1995-01-29  |  1KB  |  71 lines

  1. package Cwd;
  2. require 5.000;
  3. require Exporter;
  4.  
  5. @ISA = qw(Exporter);
  6. @EXPORT = qw(getcwd fastcwd);
  7. @EXPORT_OK = qw(chdir);
  8.  
  9. # The Apple Macintosh has a fast and canonic `pwd`, which simplifies the code
  10. # a lot. -- Matthias Neeracher <neeri@iis.ee.ethz.ch>
  11. #
  12.  
  13. # By Brandon S. Allbery
  14. #
  15. # Usage: $cwd = getcwd();
  16.  
  17. sub getcwd
  18. {
  19.     my($cwd) = `pwd`;
  20.     
  21.     chomp($cwd);
  22.     
  23.     $cwd;
  24. }
  25.  
  26.  
  27.  
  28. # By John Bazik
  29. #
  30. # Usage: $cwd = &fastcwd;
  31. #
  32. # This is a faster version of getcwd.  It's also more dangerous because
  33. # you might chdir out of a directory that you can't chdir back into.
  34.  
  35. sub fastcwd {
  36.     my($cwd) = `pwd`;
  37.     
  38.     chomp($cwd);
  39.     
  40.     $cwd;
  41. }
  42.  
  43.  
  44. # keeps track of current working directory in PWD environment var
  45. #
  46. # $RCSfile: pwd.pl,v $$Revision: 4.1 $$Date: 92/08/07 18:24:11 $
  47. #
  48. # $Log:    pwd.pl,v $
  49. #
  50. # Usage:
  51. #    use Cwd 'chdir';
  52. #    chdir $newdir;
  53.  
  54. $chdir_init = 0;
  55.  
  56. sub chdir_init{
  57.     chop($ENV{'PWD'} = `pwd`);
  58.     $chdir_init = 1;
  59. }
  60.  
  61. sub chdir {
  62.     my($newdir) = shift;
  63.     chdir_init() unless $chdir_init;
  64.     return 0 unless (CORE::chdir $newdir);
  65.     chop($ENV{'PWD'} = `pwd`);
  66. }
  67.  
  68. 1;
  69.  
  70.